<?php 
/** Load header
*/
$this->load->view('header', $template) ;
?>
<link href='http://fonts.googleapis.com/css?family=Allura' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="<?php echo base_url() ?>assets/css/formpage.css">
<!-- ---------------------------------------------------------- -->

<section class="title">
	<div class="wrapper">
		<h2 class='title'>
			Đăng Ký
		</h2>
	</div>
</section>

<section>
	<div class="wrapper form-visible">
		
		<form id="register-form" action="" method="post" accept-charset="utf-8">
			<p>
				<label class="icon"><i class="fa fa-envelope"></i> </label>
				<input type="text" name="email" placeholder=" Email">
			</p>
			<p>
				<label class="icon"><i class="fa fa-user"></i> </label>
				<input type="text" name="username" placeholder="Username">
			</p>

			<p>
				<label class="icon"><i class="fa fa-lock"></i> </label>
				<input type="password" name="password" placeholder="Password">
			</p>

			<p>
				<label class="icon"><i class="fa fa-circle-o-notch"></i></label>
				<input type="password" name="repass" placeholder="Re-password">
			</p>
			<p> &nbsp;</p>
			<p style="text-align: right; color: #4183D7">
				<strong>Thông tin chi tiết</strong>
			</p>
			<p>
				<label>Tên đầy đủ</label> 
				<input type="text" name="fullname" value="" placeholder="Họ và tên">
			</p>
			<p>
				<label>Giới tính</label> 
				<span class="group">
					<label>Nam</label>
					<input type="radio" name="gender" value="Nam">
					 &nbsp; &nbsp;
					<label>Nữ</label>
					<input type="radio" name="gender" value="Nữ">
				</span>
			</p>
			<p>
				<label>Ngày sinh: </label> 
				<input type="date" name="dob" value="">
			</p>
			<p>
				<label>Số điện thoại: </label> 
				<input type="text" name="phone" value="">
			</p>
			<p>
				<label>Công việc: </label> 
				<input type="text" name="job" value="" placeholder="">
			</p>
			<p>
				<label>Quan tâm: </label>
				<input type="text" name="interestedin" value="">
			</p>

			<p>
				<input type="submit" class="btn-submit" name="register" value="Register">
			</p>
		</form>			
	</div>
</section>

<!-- ---------------------------------------------------------- -->

<script>
	$('#register-form .btn-submit').click(function() 
	{
		if ( $('#register-form [name="email"]').val() == '' ||  
			$('#register-form [name="username"]').val() == '' || 
			$('#register-form [name="password"]').val() == '' || 
			$('#register-form [name="repass"]').val() == '' || 
			$('#register-form [name="fullname"]').val() == '')		
		{
			alert('Vui lòng nhập thông tin bắt buộc');
			return false;
		}
		if( $('#register-form [name="password"]').val() != $('#register-form [name="repass"]').val()) 
		{
			alert('Nhập lại mật khẩu không giống');
			return false;
		} 
				
		$('#register-form').submit();
		return false;
	});

	$('#register-form').submit(function() {
		$.ajax({
			type: 'POST',
			url: '/openlibraryonline/welcome/get_register',
			data: $('#register-form').serialize(),

			success: function(data) 
			{
				alert(data);
				if(data = 'Đăng ký thành công')
					window.location = "<?php echo base_url() ?>user";
			},
		});
	});

	function checkRequire() {
		// return '';
	}
</script>

<?php
/** Load Footer
*/
$this->load->view('footer') ;
?> 